Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add onClientBrowserConsoleMessage event #3676

Closed
wants to merge 9 commits into from

Conversation

gownosatana
Copy link
Contributor

This pull request adds onClientBrowserConsoleMessage event which allows more control about error/warning handling in browsers and more.

local browser = createBrowser(25, 25, true, false)

addEventHandler('onClientBrowserCreated', browser, function()
    loadBrowserURL(browser, 'http://mta/local/test.html')
end)

local logLevels = {
    [0] = 'default',
    [1] = 'verbose',
    [2] = 'info',
    [3] = 'warning',
    [4] = 'error',
    [5] = 'fatal',
    [6] = 'disable'
}

addEventHandler('onClientBrowserConsoleMessage', root, function(message, source, line, level)
    print(('Browser console message: %s (line: %d, source: %s, level: %s)'):format(message, line, source, logLevels[level]))
end)
<script>
    console.log('info test.js');
    console.warn('warn test.js');
    console.error('error test.js');
    console.info('info test.js');
    console.debug('debug test.js');
    console.trace('trace test.js');

    syuntaxErorr();
</script>

@CrosRoad95
Copy link
Contributor

Also, because you can redirect output with this function a flag could be added to do not output logs to original debug script window element createBrowser ( int width, int height, bool isLocal [, bool transparent = false [, bool outputMessagesToDebugScript = true ] ] )

@tederis tederis added the enhancement New feature or request label Aug 25, 2024
@@ -2773,6 +2773,7 @@ void CClientGame::AddBuiltInEvents()
m_Events.AddEvent("onClientBrowserTooltip", "text", NULL, false);
m_Events.AddEvent("onClientBrowserInputFocusChanged", "gainedfocus", NULL, false);
m_Events.AddEvent("onClientBrowserResourceBlocked", "url, domain, reason", NULL, false);
m_Events.AddEvent("onClientBrowserConsoleMessage", "message, source, line, level", NULL, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullptr instead of NULL

Copy link
Contributor Author

@gownosatana gownosatana Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey tracerds, can I ask you to stop making random comments on random pull requests? here it would be absolutely radicoolous to change null to nullptr when ALL of events use null. this is public repo and not your private project where you change anything because you prefer nullptr over null. thanks 🙏👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey tracerds, can I ask you to stop making random comments on random pull requests? here it would be absolutely radicoolous to change null to nullptr when ALL of events use null. this is public repo and not your private project where you change anything because you prefer nullptr over null. thanks 🙏👍

That the older code in this file makes use of NULL is irrelevant. You are introducing new code and should therefore use the proper modern methods. In this case nullptr over NULL. It's a valid comment from Tracer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You come here edit code thats been created by the community.
Its not my preference. There are standards. Read them BEFORE creating a PR.
If you dont like the way it is, dont contribute.
If you want to contribute, follow the guidelines.
Dont resolve conversations when you dont change anything.
Just because in your opinion you can do whatever you want doesnt give you the right to do so. Either follow the guidelines or dont contribute

Comment on lines +310 to +315
CLuaArguments Arguments;
Arguments.PushString(strMessage);
Arguments.PushString(strSource);
Arguments.PushNumber(line);
Arguments.PushNumber(level);
CallEvent("onClientBrowserConsoleMessage", Arguments, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

above, everywhere is used like this, it's not problem that needs to be fixed to get merged, if you really want to change things like this just create refactor pull request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New PRs shouldn't introduce code that requires a refactor later to meet current standards. Could go even deeper, hungarian notation shouldn't be used anymore.

@@ -2778,6 +2778,7 @@ void CClientGame::AddBuiltInEvents()
m_Events.AddEvent("onClientBrowserTooltip", "text", NULL, false);
m_Events.AddEvent("onClientBrowserInputFocusChanged", "gainedfocus", NULL, false);
m_Events.AddEvent("onClientBrowserResourceBlocked", "url, domain, reason", NULL, false);
m_Events.AddEvent("onClientBrowserConsoleMessage", "message, source, line, level", NULL, false);
Copy link
Contributor

@FileEX FileEX Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change NULL to nullptr for onClientBrowserConsoleMessage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't change anything, it's like this everywhere, you can open pull request to refactor mta code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't change anything, it's like this everywhere, you can open pull request to refactor mta code

It changes everything. Why should someone open a pull request just to clean after you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't change anything, it's like this everywhere, you can open pull request to refactor mta code

In accordance with the guidelines and current C++ conventions, you should use nullptr instead of NULL, as everyone else does in this repository. No one is going to clean up after you because you're too lazy to make the changes required by the coding standards. We follow the principle that when creating new code, we adhere to the latest guidelines and avoid creating more mess than there already is. If you don't follow the coding guidelines, your PR simply won't be considered, and no one will likely want to merge it. It's your choice whether to spend a minute making this change or risk having all the time you invested in this PR go to waste

@FileEX
Copy link
Contributor

FileEX commented Sep 4, 2024

Personally, I believe this PR should not be merged until the author implements the changes required by the guidelines. Marking an ongoing discussion as resolved does not solve the problem; it only reflects the author's laziness and disregard for coding standards, as they choose to follow their own rules instead.

@CrosRoad95
Copy link
Contributor

Any ETA when it will be merged?

@Nico8340
Copy link
Contributor

Nico8340 commented Oct 5, 2024

Any ETA when it will be merged?

This is solely up to the author, because it seems that he does not plan to follow the contribution guidelines and rules of the project in the future either, since several cleanups were necessary even after his previous contributions, and he did not complete the documentation despite the team's request, which in the case of this pull request a pre-requirement.

The biggest problem is that the author probably won't deal with the suggested changes, since more than a month has passed (at least from his behavior and previous contributions), so it's possible that someone else will have to implement this feature.

@CrosRoad95
Copy link
Contributor

CrosRoad95 commented Oct 5, 2024

Mta is not a job, but aparently If nullptr over NULL is so important

@Nico8340
Copy link
Contributor

Nico8340 commented Oct 5, 2024

Mta is not a job, but aparently If nullptr over NULL is so important

It's not a job, but neither is it the job of others to clean up and prepare documentation after this guy's contributions..
If they don't want to follow the guidelines, why contribute at all?

@CrosRoad95
Copy link
Contributor

CrosRoad95 commented Oct 5, 2024

And then we have addendum, to addendum with cleanup and X commits for 1 feature. But at least nullptr is used instead of NULL
c87ff84
3084934
866cd85

Thats how you discurge people from contributing, you can later make pr that changes all NULL into nullptr therefore people copy correct example instead of wrong

Best part: two commits i linked above are from person who really want to block pr over 1 word

@Lpsd
Copy link
Member

Lpsd commented Oct 5, 2024

Let's stay on-topic, mistakes happen and sometimes things get missed.

If something is in the guideline it should be followed without questioning the person who raised it - don't shoot the messenger! We don't need to create a drama over 10 lines of code. After all, these guidelines were created in-part to prevent such unnecessary heated discussions over preference based issues, or where the difference in usage is insignificant.

If you don't agree with a guideline, a discussion can be opened on the mtasa-docs repo, or in the development Discord; however you'd still need to adhere to the guideline in your PR, until it changes.

People might not be aware of mtasa-docs as it's fairly new - but now you know! 😉

@FileEX
Copy link
Contributor

FileEX commented Oct 5, 2024

And then we have addendum, to addendum with cleanup and X commits for 1 feature. But at least nullptr is used instead of NULL c87ff84 3084934 866cd85

Thats how you discurge people from contributing, you can later make pr that changes all NULL into nullptr therefore people copy correct example instead of wrong

Best part: two commits i linked above are from person who really want to block pr over 1 word

I basically wasn't planning on replying anymore, but since you brought up my commits as an example, I'll throw in my two cents.

Don’t you think comparing the interface to changing a single word is out of place? It was the mistakes of previous developers that caused the issues, and I only adjusted it for the isPlayerCrosshairVisible function. Interfaces and offsets are much more complex topics where it's far easier to make a mistake than just changing one word.

Best part: two commits i linked above are from person who really want to block pr over 1 word

I can’t block anything, I’m not the decision-maker. I simply expressed my opinion about the author’s behavior, and that’s all. If someone from the staff wants to, they’ll just ignore it and merge the PR.

The guidelines were created to be followed as much as possible, not just to exist like before. There supposedly were guidelines, but in reality, everyone ignored them. Those days are over, and it’s time to accept that. What’s the point in debating this PR if the author himself doesn’t want to change a single word and prefers for the PR to sit indefinitely? You know the author well, so if you care about this PR, ask him to fix it, instead of pouring out your endless grievances about how everyone around is bad and how horrible the guidelines are. Additionally, you claim that this discourages people from contributing to the project. If someone wants to contribute, they should accept the rules in place and follow the guidelines, not do things their own way just because they don’t feel like fixing something. What’s the point of that kind of cooperation? You’re starting some weird drama over literally one word, which the author could have changed in 10 seconds if he wanted to. The fact that this PR still hasn’t been merged isn’t the fault of the guidelines or mine. It’s purely due to the author’s laziness. Lately, you haven’t contributed anything meaningful; you just create drama over the guidelines, and then you’re surprised that your comments were marked as off-topic. Unbelievable.

@Dutchman101
Copy link
Member

Dutchman101 commented Oct 5, 2024

In the author's (gownosatana, aka borsuk/LibertyPL) other PR's we have seen the same trend of negative behavior, derailing into conflict-seeking. This isn't unexpected, coming from a few people in this "group" that have various aggravations against MTA and the way this project is being managed, as well as their punitive histories within the MTA community discord and the game itself; both have been malicious in the past, in both a cheating and server hacking/exploiting (blackhat) sense.

I'm talking about the author, borsuk, and CrosRoad95 here, as well as their like-minded friends.
As there has been inaction besides my one comment on your other PR to make short work of all this negative behavior, i will do it now: your PR's will be closed and it's better if you not try to contribute to mtasa-blue again. I very much think that you guys are here to cause friction/dramas between MTA Contributors, and reduce everyone's mood, over actually looking to contribute. Either way, your attitude is incompatible with our way of working.

Also, more to the subject; you are unwilling to cooperate in order to get this PR where it needs to be, among other things. This isn't going to work, also a good reason why i firmly believe you just shouldn't be trying to contribute anymore, you're not really welcome.

This project is managed by us, not you. End of story, the whole thing can't be argued..

@Dutchman101 Dutchman101 closed this Oct 5, 2024
@multitheftauto multitheftauto locked as too heated and limited conversation to collaborators Oct 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants